#include<bits/stdc++.h>
using namespace std;
typedef struct node{
	char data;
	struct node *lchild,*rchild;
}BTNode;
typedef struct node * BTree;
void CreateBTree(BTree &BT,string str);
void LevelOrder(BTree BT);
int main(){
	BTree BT;
	string str;
	cin>>str;
	CreateBTree(BT,str);
	LevelOrder(BT);
	return 0;
}
void CreateBTree(BTree &BT,string str){
	queue<BTree>q;
	BTree T;
	int i=0;
	if(str[1]=='#'||str[1]=='\0') BT=NULL;
	else {
		BT=new BTNode;
		BT->data=str[1];
		BT->lchild=BT->rchild=NULL;
		q.push(BT);
	}
	i=2;
	while(!q.empty()){
		T=q.front();
		q.pop();
		if(str[i]=='#') T->lchild=NULL;
		else {
			T->lchild=new BTNode;
			T->lchild->data=str[i];
			T->lchild->lchild=T->lchild->rchild=NULL;
			q.push(T->lchild);
		}
		i++;
		if(str[i]=='\0') break;
		if(str[i]=='#') T->rchild=NULL;
		else {
			T->rchild=new BTNode;
			T->rchild->data=str[i];
			T->rchild->lchild=T->rchild->rchild=NULL;
			q.push(T->rchild);
		}
		i++;
		if(str[i]=='\0') break;
	}
}
void LevelOrder(BTree BT){
	BTree p;
	queue<BTree>Q;
	Q.push(BT);
	int i=0;
	if(BT==NULL) cout<<"NULL";
	else 
	while(!Q.empty()){
		p=Q.front();
		Q.pop();
		if(i==0) cout<<p->data;
		else cout<<" "<<p->data;
		i=1;
		if(p->lchild!=NULL){
			Q.push(p->lchild);
		}
		if(p->rchild!=NULL){
			Q.push(p->rchild);
		}
	}
}
